#include "pch.h"

#include "iosystem/textwriter.h"



namespace IO
{

	///
	RE_ImplementClass('TXTW', IO::TextWriter, IO::StreamWriter);





	///
	TextWriter::TextWriter()
	{

	}


	///
	TextWriter::~TextWriter()
	{

	}



	///
	void TextWriter::WriteChar(uchar c)
	{
		this->m_stream->Write(&c, sizeof(c));
	}


	///
	void TextWriter::WriteString(const Helper::String & str)
	{
		this->m_stream->Write(str.GetAsCharPtr(), str.Length());
	}


	///
	void TextWriter::WriteFormat(const char * fmt, ...)
	{
		va_list args;
		va_start(args, fmt);

		Helper::String temp;

		temp.FormatArgList(fmt, args);

		this->m_stream->Write(temp.GetAsCharPtr(), temp.Length());

		va_end(args);
	}


	///
	void TextWriter::WriteLine(const Helper::String & line)
	{
		this->WriteString(line);

		this->WriteChar('\n');
	}


	///
	void TextWriter::WriteParagraph(const Helper::Array<Helper::String> & lines)
	{
		for(tIndex i = 0; i < lines.Size(); i++)
			this->WriteLine(lines[i]);
	}

}